package ModelLayer;

import java.util.ArrayList;

/**
 * Write a description of class LendCon here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class LendCon
{
    // instance variables - replace the example below with your own
    private ArrayList<Lending> lend;
    private static LendCon instance;
    
    private LendCon()
    {
        lend = new ArrayList<Lending>();
    }
    
    public static LendCon getInstance()
    {
        if(instance == null)
        {
            instance = new LendCon();
        }
        return instance;
    }
    
    public void addLend(Lending l)
    {
        lend.add(l);
    }
    
    public boolean deleteLend(int dvdID, int copyID)
    {
        int index = 0;
        Lending l = null;
        boolean found = false;
        
        while(index < lend.size() && !found)
        {
            l = lend.get(index);
            
            if(l.getDVDID() == dvdID && l.getCopyID() == copyID)
            {
                lend.remove(index);
                found = true;
            }
            else
            {
                index++;
            }
        }
        
        return found;
    }
    
    public ArrayList getArrayList()
    {
        return lend;
    }
    
    public Lending getLend(int index)
    {
        return lend.get(index);
    }
}
